package com.lyz.dataStructure.algorithm.商汤科技2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 18:55
 * @Description:
 **/

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import java.util.Scanner;
import java.util.Stack;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/19 18:55
 *@Description:
 **/
public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] st = s.split(" ");

        for(int i =0;i<st.length;i++){
            st[i] = st[i];
        }
        System.out.println(eval(st));
    }

    public static int eval(String[] tokens){
        Stack<Integer> stack = new Stack<>();
        for(String s:tokens){
            if(s.equals("+")){
                stack.push(stack.pop()+stack.pop());

            }else if(s.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(s.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else if(s.equals("/")){
                int num1 = stack.pop();
                stack.push(stack.pop()/num1);
            }else {
                stack.push(Integer.parseInt(s));
            }
        }
        return stack.pop();
    }
}
